package com.whu.waterworks.action;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.whu.waterworks.dto.GisTodayStationData;
import com.whu.waterworks.model.Realtimedata;
import com.whu.waterworks.service.DataService;
import com.whu.waterworks.service.GisStationHistoryDataService;

public class GisGetTodayStationDataAction extends ActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 7649755400326681491L;
	private String code;
	private String type;
	// 返回的值
	private List<GisTodayStationData> list;
	private GisStationHistoryDataService gisStationHistoryDataService;

	public String getTodayStatonDatas() {
		list = new ArrayList<>();
		SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd");
		Date now = new Date();
		String day = format.format(now);
		List<Realtimedata> realtimedatas = gisStationHistoryDataService.getDataByTwoTimeLimitTenRecords(code,
				type, day, day);
		System.out.println("GetDataAction realtimedatas.size()="
				+ realtimedatas.size());
		for (Realtimedata realtimedata : realtimedatas) {

			GisTodayStationData data = new GisTodayStationData();
			data.setValue(realtimedata.getValue());
			data.setDate(realtimedata.getId().getTime().substring(11));
			list.add(data);
		}
		return SUCCESS;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public List<GisTodayStationData> getList() {
		return list;
	}

	public void setList(List<GisTodayStationData> list) {
		this.list = list;
	}

	public GisStationHistoryDataService getGisStationHistoryDataService() {
		return gisStationHistoryDataService;
	}

	public void setGisStationHistoryDataService(
			GisStationHistoryDataService gisStationHistoryDataService) {
		this.gisStationHistoryDataService = gisStationHistoryDataService;
	}

    
}
